package ooday05;

import java.util.concurrent.Callable;


public class Test {
    public static void main(String[] args) {
        Chick xh = new Chick();
        xh.name="小黄鸡";
        xh.age = 2;
        xh.index = 1;
        xh.eat();//小黄鸡吃
        xh.agg();//小黄鸡下蛋
        xh.call();//小黄鸡叫

        Dog dog1 = new Dog("小黄狗",1,2);
        dog1.lookDoor();//小黄狗看门
        dog1.eat();//小黄狗吃
        dog1.drink();//小黄狗喝
        dog1.call();//小黄狗叫

        Fish[] fish = new Fish[3];
        fish[0] = new Fish("小黄鱼",1,3);
        fish[1] = new Fish("小红鱼",2,4);
        fish[2] = new Fish("小蓝鱼",3,5);
        for (int i = 0; i <fish.length ; i++) {
            fish[i].swim();//345鱼游泳
        }

        // 狗  鱼多态喝
        Animal[] animals = new Animal[3];
        animals[0] = new Dog("小白狗",3,6);
        animals[1] = new Dog("小蓝狗",4,7);
        animals[2] = new Fish("小花鱼",4,8);
        for (int i = 0; i <animals.length ; i++) {
            animals[i].drink();
            animals[i].eat();//678狗和鱼喝 吃
            if (animals[i] instanceof Dog){
                ((Dog) animals[i]).lookDoor();
            }//67看门
            if (animals[i] instanceof Fish){
                ((Fish) animals[i]).swim();
            }//8游泳
        }
    }
}
